package com.cnap.multiclouldmgmt.model.enums;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 枚举类型
 * @author dyq
 */
public enum CloudVendorsEnum {

    HuaWeiCloud("华为云","huaweicloud","Huawei","public"),

    Aliyun("阿里云","aliyun","Aliyun","public"),

    TencentCloud("腾讯云","tencentCloud","Tencent","public"),

    WoCloud("联通云","Wocloud","Wocloud","public"),

    Openstack("Openstack","Openstack","Openstack","private"),

    InspurCloud("浪潮InCloud","InspurInCloud","InspurInCloud","private");

    //PrivateCloud("私有云","privateCloud","private","private");

    private String chineseDescribe;

    private String describe;

    private String cloudType;

    private String cloudScope;

    CloudVendorsEnum(String chineseDescribe, String describe,String cloudType,String cloudScope) {

        this.chineseDescribe = chineseDescribe;
        this.describe = describe;
        this.cloudType = cloudType;
        this.cloudScope = cloudScope;
    }

    public static String getCloudScopeByCloudeType(String cloudType){

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getCloudType().equals(cloudType)){

                return enumObj.getCloudScope();
            }
        }

        return "public";
    }

    public static String changeToCloudeType(String cloudVendor) {

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getDescribe().equals(cloudVendor)){

                return enumObj.getCloudType();
            }
        }

        return cloudVendor;
    }

    public static CloudVendorsEnum getCloudVendorByCloudType(String cloudType) {

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getCloudType().equals(cloudType)){

                return enumObj;
            }
        }

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getDescribe().equals(cloudType)){

                return enumObj;
            }
        }
        return null;
    }

    /**
     * get
     *
     * @return ChineseDescribe
     */
    public String getChineseDescribe() {
        return chineseDescribe;
    }

    /**
     * get
     *
     * @return CloudScope
     */
    public String getCloudScope() {
        return cloudScope;
    }

    /**
     * set
     *
     * @param cloudScope cloudScope
     */
    public void setCloudScope(String cloudScope) {
        this.cloudScope = cloudScope;
    }

    /**
     * set
     *
     * @param chineseDescribe chineseDescribe
     */
    public void setChineseDescribe(String chineseDescribe) {
        this.chineseDescribe = chineseDescribe;
    }

    /**
     * get
     *
     * @return Describe
     */
    public String getDescribe() {
        return describe;
    }

    /**
     * set
     *
     * @param describe describe
     */
    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public static String getChineseDescribeByDescribe(String describe){
        
        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getDescribe().equals(describe)){

                return enumObj.getChineseDescribe();
            }
        }

        return describe;
    }

    public static String getDescribeByChineseDescribe(String chineseDescribe){

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getChineseDescribe().equals(chineseDescribe)){

                return enumObj.getDescribe();
            }
        }

        return chineseDescribe;
    }

    public static String getDescribeByCloudeType(String cloudType){

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getCloudType().equals(cloudType)){

                return enumObj.getDescribe();
            }
        }

        return cloudType;
    }

    public static String getCloudeTypeByDescribe(String describe){

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            if (enumObj.getDescribe().equals(describe)){

                return enumObj.getCloudType();
            }
        }

        return describe;
    }

    /**
     *
     * @return List<String>
     */
    public static List<String> getAllCloudVendors(){

        List<String> result = new ArrayList<>();

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){

            result.add(enumObj.getDescribe());
        }

        return result;
    }

    /**
     * get
     *
     * @return CloudType
     */
    public String getCloudType() {
        return cloudType;
    }

    /**
     * set
     *
     * @param cloudType cloudType
     */
    public void setCloudType(String cloudType) {
        this.cloudType = cloudType;
    }

    public static List<CloudVendorsEnum> getAllPrivateClouderVendor(){

        List<CloudVendorsEnum> result = new ArrayList<>();

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){
            if (StringUtils.equalsIgnoreCase(enumObj.getCloudScope(),"private"))

            result.add(enumObj);
        }

        return result;
    }

    public static List<CloudVendorsEnum> getAllPublicClouderVendor(){

        List<CloudVendorsEnum> result = new ArrayList<>();

        for(CloudVendorsEnum enumObj : CloudVendorsEnum.values()){
            if (StringUtils.equalsIgnoreCase(enumObj.getCloudScope(),"public"))

                result.add(enumObj);
        }

        return result;
    }

}
